package cn.youframe.sample.code;

import cn.youframe.frame.base.BaseCtrl;
import cn.youframe.frame.beans.TableInfoVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * User: Administrator
 * DateTime: 13-2-17: 下午12:12
 */
@Controller
@RequestMapping(value = "/sample")
public class CodeCtrl extends BaseCtrl {
    @Autowired
    private CodeService codeService;
    @RequestMapping(value = "/CodeCtrl!table2Java.do")
    public @ResponseBody TableInfoVO table2Java(HttpServletRequest request){
        long startTime=System.currentTimeMillis();
        TableInfoVO tabVo=new TableInfoVO();
        String tabName= StringUtils.stripToEmpty(request.getParameter("tabName"));
        tabName=tabName.toUpperCase();
        String pkgName=request.getParameter("pkgName");
        String charset=request.getParameter("charset");
        String retStr=codeService.genEntity(tabName,pkgName,charset);
        tabVo.setComments(retStr);
        long oprTime=System.currentTimeMillis()-startTime;
        logger.info("执行完成！耗时：" + oprTime + " 毫秒"+request.getCharacterEncoding());// 返回到前台
        return tabVo;

    }
}
